﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public interface IKeyFrameUpdater
{
   void KeyFrameUpdate(long keyId, long keyTime);
}

public class KeyFrameTimeManager
{
    LinkedList<IKeyFrameUpdater> Updaters = new LinkedList<IKeyFrameUpdater>();
    public long CurKeyFrameTime;
    public long CurKeyFrameId;
     
    public LinkedListNode<IKeyFrameUpdater> AddUpdater(IKeyFrameUpdater updater)
    {
       return this.Updaters.AddLast(updater);
    }

    public void RemoveUpdater(IKeyFrameUpdater updater)
    {
        this.Updaters.Remove(updater);
    }
    public void RemoveUpdater(LinkedListNode<IKeyFrameUpdater> updaterNode)
    {
        this.Updaters.Remove(updaterNode);
    }
    public void UpdateKeyFrame(long  keyId,long keyTime)
    {
        this.CurKeyFrameId = keyId;
        this.CurKeyFrameTime = keyTime;
        foreach (IKeyFrameUpdater updater in Updaters)
        {
            updater.KeyFrameUpdate(keyId,keyTime);
        }
    }

}
